# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /usr/local/portage/net-www/mplayerplug-in-cvs/mplayerplug-in-cvs-9999.ebuild,v 1.0 2005/05/17 18:00:00 Apache2 Exp $

inherit nsplugins multilib toolchain-funcs

DESCRIPTION="mplayer plug-in for Mozilla"
HOMEPAGE="http://mplayerplug-in.sourceforge.net/"
SRC_URI="http://mplayerplug-in.sourceforge.net/mplayerplug-in-daily.tar.gz"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~ppc x86 ~sparc ~ia64"
IUSE="quicktime wmp google real"
C=${WORKDIR}/mplayerplug-in

DEPEND="
	>=media-video/mplayer-0.92
	net-libs/gecko-sdk
	gtk2? (
		>=x11-libs/gtk+-2.2.0
		dev-libs/atk
		>=dev-libs/glib-2.2.0
		>=x11-libs/pango-1.2.1 )
	!gtk2? (
		=x11-libs/gtk+-1.2*
		=dev-libs/glib-1.2* )
	!net-www/mplayerplug-in"

src_compile() {
	local myconf
	myconf="${myconf} --with-gecko-sdk=/usr/$(get_libdir)/gecko-sdk --enable-gtk2"
	if use wmp; then
		einfo Configuring to build with Windows Media Player support
		myconf="${myconf} --enable-wmp"
		plugins="${plugins} wmp"
	fi
	if use quicktime; then
		einfo Configuring to build with Quick Time support
		myconf="${myconf} --enable-qt"
		plugins="${plugins} qt"
	fi
	if use real; then
		einfo Configuring to build with RealMedia support
		myconf="${myconf} --enable-rm"
		plugins="${plugins} rm"
	fi
	if use google; then
		einfo Configuring to build with Google Video support
		myconf="${myconf} --enable-gmp"
		plugins="${plugins} gmp"
	fi
	cd ${C}
	econf ${myconf} || die
	emake || die
}

src_install() {
	cd ${C}
	exeinto /usr/lib/mozilla/plugins
	doexe mplayerplug-in.so || die "plugin failed"
	inst_plugin /usr/lib/mozilla/plugins/mplayerplug-in.so

	# Install .xpt, bug #83162
	insinto /usr/lib/mozilla/components
	doins mplayerplug-in.xpt
	inst_plugin /usr/lib/mozilla/components/mplayerplug-in.xpt

	echo $
	for plugin in $plugins; do
		exeinto /usr/lib/mozilla/plugins
		doexe "mplayerplug-in-${plugin}.so" || die "plugin ${plugin} failed"
		inst_plugin "/usr/lib/mozilla/plugins/mplayerplug-in-${plugin}.so"
		
		insinto /usr/lib/mozilla/components
		doins "mplayerplug-in-${plugin}.xpt" || die "plugin ${plugin} xpt failed"
		inst_plugin "/usr/lib/mozilla/components/mplayerplug-in-${plugin}.xpt"
	done

	insinto /etc
	doins mplayerplug-in.conf

	dodoc ChangeLog INSTALL README TODO DOCS/tech/*.txt
}
